<?php
	/**
	 * 修改玩家昵称
	 */
    class EditNickName extends APIBase {
		
		public $tag = "EditNickName";
    	public $isLogin = true;
		
		public function before() {
			$this->initCacheRedis();
			$this->initMysql();
			return true;
		}
		public function logic() {
			$uid = $this->uid;
			$nickName = filter_emoji($this->param['nickname']);
			if($nickName!="" || $nickName!=null){
			    $nickName = urldecode($nickName);
				if(mb_strlen($nickName,'utf-8')<=8){
			        $this->data_redis->hMset('hu:'.$uid,array('name'=>$nickName));
			        $user = $this->data_redis->hMget('hu:'.$uid,array('name'));
			        if($user['name'] == $nickName){
				        $this->returnData($user['name']);
			        }else{
				        $this->returnError(301,'Edit fail!');
			        }
				}else{
					$this->returnError(303,'昵称长度不能超过8个字!');
				}
			}else{
				$this->returnError(302,'昵称不能为空!');
			}
		}
		
        public function after() {
			$this->deinitCacheRedis();
		}
    }
?>
